package logic

import (
	"context"
	"wx/models/mysql"

	"wx/wxrpc/internal/svc"
	"wx/wxrpc/wxrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowLogic {
	return &ShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ShowLogic) Show(in *wxrpc.ShowRequest) (*wxrpc.ShowResponse, error) {
	// todo: add your logic here and delete this line
	var wx []mysql.WeiXin
	mysql.DB.Find(&wx)
	var wxlist []*wxrpc.Show
	for _, m := range wx {
		show := wxrpc.Show{
			Id:      int64(m.ID),
			Context: m.Context,
			Image:   m.Image,
			UserId:  int64(m.ID),
			Mobile:  m.Mobile,
		}
		wxlist = append(wxlist, &show)
	}
	return &wxrpc.ShowResponse{
		List: wxlist,
	}, nil
}
